<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    function Person (name, age, gender) {
        this.name = name
        this.age = age
        this.gender = gender
        // 方法
        if (typeof this.sayName !== 'function') {
            Person.prototype.sayName = function () {
                console.log(this.name)
            }
        }
    }

    var bailongma = new Person('小白龙', '500', '不详')
    bailongma.sayName()

</script>

</body>
</html>
